﻿using AMAP.Domain;
using AMAP.ServiceClasses.Common;
using AMAP.ServiceInterfaces;
using AMAP.ServiceInterfaces.Common;
using System;
using System.Collections.Generic;
using System.Linq;

namespace AMAP.ServiceClasses
{
    public class ExternalOrderService : BaseRepositoryService<ExternalOrder>, IExternalOrderService
    {
        public ExternalOrderService(IDatabaseFactory databaseFactory)
            : base(databaseFactory)
        {
        }

        public IList<ExternalOrder> GetStock()
        {
            return this.dataContext.ExternalOrderSet.Where(e => e.RemainedQuantity > 0).ToList<ExternalOrder>();
        }

        public IList<ExternalOrder> GetLastUnupdatedExternalOrder()
        {
            DateTime Limit = DateTime.Now.AddDays(-5);
            return this.dataContext.ExternalOrderSet.Where(e => e.ProvidedQuantity == -1 && e.CreationDate > Limit).ToList<ExternalOrder>();
        }
    }
}
